/*******************************************************************************
 * Copyright (c) 2011 LegSem.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl-3.0.txt
 * 
 * Contributors:
 *     LegSem - initial API and implementation
 ******************************************************************************/
package com.legsem.legstar.jca;

import javax.resource.ResourceException;
import javax.resource.spi.ManagedConnection;

import com.legsem.legstar.cci.LegStarConnection;
import com.legstar.messaging.HostEndpoint;

public interface LegStarManagedConnection extends ManagedConnection {

    /**
     * @return the host endpoint parameters
     */
    public HostEndpoint getHostEndpoint();

    /**
     * @return the host connection
     */
    public com.legstar.messaging.LegStarConnection getHostConnection();

    /**
     * Notify listeners that a transaction is started.
     */
    public void transactionStarted();

    /**
     * Notify listeners that a transaction is committed.
     */
    public void transactionCompleted();

    /**
     * Notify listeners that a transaction is rolled back.
     */
    public void transactionRolledback();

    /**
     * @return the current CCI connection
     */
    public LegStarConnection getConnection();

    /**
     * close the underlying host connection
     * 
     * @throws ResourceException if close fails
     */
    public void close() throws ResourceException;

    /**
     * An error occurred
     * 
     * @param exception the exception caught
     */
    public void onError(Exception exception);
}
